package com.carlyang.studentinfo.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
	public static final String TAG = "DateUtil";
	public static String formatDate(Date date,String format) {
		String restlt="";
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		if (date!=null) {			
			restlt=sdf.format(date);
		}
		return restlt;
	}
	
	public static Date formatString(String date,String format){
		Date restlt=null;
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		if (StringUtil.isNotEmpty(date)) {			
			try {
				restlt = sdf.parse(date);
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return restlt;
	}
	
	public static void main(String[] args) {
//		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//		try {
//			LogUtil.i(TAG, sdf.parse("1993-11-12").toString());
//		} catch (ParseException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		LogUtil.i(TAG, formatString("1991-12-11","yyyy-MM-dd").toString());
	}
}
